
import { Component, OnInit, Injector, TemplateRef, ViewChild, Input } from '@angular/core';
import { NgZorroPageBaseComponent } from '../../core/ng-zorro-page-base-component/ng-zorro-page-base-component.component';
import { HttpService } from "../../core/service/http.service";
import { HttpClient } from "@angular/common/http";
import { Router, NavigationExtras } from "@angular/router";
import {
  AndOr, Compare, ExpressionPair, PagedResultDto, PagerSearchInput, ElementViewType, BaseComponentConfig,
  SystemFormControl, FieldType, ElementShowType, CustomNavigation, ClassInfoOutput, NavigatType, ArSystemFormControl, ClassSchool
} from "../..";
import { NzMessageService, NzModalService } from 'ng-zorro-antd';
import { CityListComponent } from '../school/cityList';
import {
  FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators,
  FormControl
} from "@angular/forms";


@Component({
  selector: 'app-myscore',
  templateUrl: './myscore.component.html',
  styleUrls: ['./myscore.component.scss']
})
export class MyscoreComponent extends NgZorroPageBaseComponent implements OnInit {


  aclear; // 定时器
  traincourse; // 实训课程
  typedrill; // 类型演练
  drillrole; // 演练角色
  listEntitiesdata; // 实训课程arr
  listEntitiesdatatype; // 类型演练arr
  listEntitiesdatarole; // 演练角色arr
  getid;

  ngOnInit() {
    this.getdrill();
    this.IniObserver.subscribe(sb => {
      this.getEntityList();
    });

    this.listSearchValue = [
      new ExpressionPair('DrillSubject', "", Compare.Contains, AndOr.And),
    ];
    this.listSearchValue[0].propertyValue = undefined;
  }
  constructor(
    injecter: Injector,
    public http1: HttpService,
    private modalService: NzModalService,
    public http: HttpClient

  ) {
    super(injecter,
      new BaseComponentConfig(
        "StudentInfo/GetAllScoreByStudentGl",
        "",
        "",
        "",
        "",
        "id",
        "",
        "",
        [],
        "",
        { Edit: false, Dell: false },
      ));

  }


  // 实训课程搜索触发事件
  async searchChange(searchText: string) {
    const that = this;
    clearTimeout(this.aclear);
    this.aclear = setTimeout(() => {
      that.sealist(searchText);
    }, 1000);
  }
  sealist(i) {
    const datalist = { "Name": i };
    this.listEntitiesdata = [];
    this.http1.post<any>("School/GetSchoolToTen", datalist).then(e => {
      this.listEntitiesdata = e;

    });
  }

  // 类型演练搜索触发事件
  async searchChangetype(searchText: string) {
    const that = this;
    clearTimeout(this.aclear);
    this.aclear = setTimeout(() => {
      that.sealisttype(searchText);
    }, 1000);
  }
  sealisttype(i) {
    const datalist = { "Name": i };
    this.listEntitiesdatatype = [];
    this.http1.post<any>("School/GetSchoolToTen", datalist).then(e => {
      this.listEntitiesdatatype = e;

    });
  }


  // 演练角色搜索触发事件
  async searchChangerole(searchText: string) {
    const that = this;
    clearTimeout(this.aclear);
    this.aclear = setTimeout(() => {
      that.sealistrole(searchText);
    }, 1000);
  }
  sealistrole(i) {
    const datalist = { "Name": i };
    this.listEntitiesdatarole = [];
    this.http1.post<any>("School/GetSchoolToTen", datalist).then(e => {
      this.listEntitiesdatarole = e;

    });
  }


  // 搜索
  drillsearch() {
    this.listSearchValue[0].propertyValue = this.getid;
    this.getEntityList();
  }


  classsearchinput(e) {
    if (e.keyCode === 13) {
      this.drillsearch();
    }
  }

  // 实训课程选择触发事件
  provinceChangesol(e) {

    this.getid = e;


  }

  // 取消搜索
  drillcancle() {
    this.listSearchValue[0].propertyValue = undefined;
    this.getEntityList();
  }
  getdrill() {
    this.http1.get<any>("StudentInfo/GetStudentDrillSubject").then(e => {
      this.listEntitiesdata = e;

    });
  }

}
